package com.xframework.security.model;

import com.xframework.model.BaseModel;
import com.xframework.security.util.WxConstant;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.Map;

public class WxMessageTemplateSend extends BaseModel {
    private String template_id = "qNveWJ2oJrdaMt3a6_-uYrYV2kNUVj1DTN_dz640_Es";

    private String touser;

    private String url;

    private String topcolor = "#FF0000";

    private Map<String, Map<String, String>> data;

    public WxMessageTemplateSend(String touser, String redirectUrl, String template_id, Map<String, Map<String, String>> data) throws UnsupportedEncodingException {
        this.setTouser(touser);
        this.setUrl(MessageFormat.format(WxConstant.WX_AUTHORIZE_URL, WxConstant.wxAppId, URLEncoder.encode(redirectUrl, StandardCharsets.UTF_8.name())));
        this.setTemplate_id(template_id);
        this.setData(data);
    }

    public String getTouser() {
        return touser;
    }

    public void setTouser(String touser) {
        this.touser = touser;
    }

    public String getTemplate_id() {
        return template_id;
    }

    public void setTemplate_id(String template_id) {
        this.template_id = template_id;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getTopcolor() {
        return topcolor;
    }

    public void setTopcolor(String topcolor) {
        this.topcolor = topcolor;
    }

    public Map<String, Map<String, String>> getData() {
        return data;
    }

    public void setData(Map<String, Map<String, String>> data) {
        this.data = data;
    }

}